<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content">
  <div class="top">
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <table class="list">
      <thead>
        <tr>
        <td class="left">编辑目录</td>
        </tr>
      </thead>
      <form action="" id="category_form" method="POST">
      <tbody>
      <tr>
        <td class="left">
        目录名称:<input type="text" id="cat_name" name="cat_name"  value="<?php echo $cat_name;?>"/>
        <input type="hidden" id="cat_id" name="cat_id"  value="<?php echo $cat_id;?>"/> 
        <input type="submit" id="category_form_submit" value="更新" class="buttons center"/>
        </td>
    </tr>
    </tbody>
    </form>
    </table>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<script language="javascript">
$(document).ready(function(){
$('.success img, .warning img, .attention img, .information img').live('click', function() {
	$(this).parent().fadeOut('slow', function() {
		$(this).remove();
	});
});
    $("#category_form").submit(function(){
		var options = {
                url:        "index.php?route=category/manger/update",
                dataType:        "json",
				beforeSubmit:  validate,  // pre-submit callback
				success:       showResponse  // post-submit callback
		};
        jQuery(this).ajaxSubmit(options);
        return false;
    });
});
function validate()
{
    var cat_name = $("#cat_name").val();
    if(cat_name == '')
    {
        $('.success, .warning, .attention, .information').remove();
        $('#notification').html('<div class="warning" style="display: none;">目录不能为空<img src="home/view/image/close.png" alt="" class="close" /></div>');
        $('.warning').fadeIn('slow');
        return false;
    }
    
}
function showResponse(json)
{
    $('#category_form').clearForm();
    if (json['success']) {
        $('.success, .warning, .attention, .information').remove();
        $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="home/view/image/close.png" alt="" class="close" /></div>');
        $('.success').fadeIn('slow');
        
        $('html, body').animate({ scrollTop: 0 }, 'slow'); 
    }
    var url  = 'index.php?route=category/list';
    redirecturl(url);
    return false;
}
</script>
<?php echo $footer; ?> 